// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  let name = event.name
  let submitter = event.submitter
  let category = event.category
  return await db.collection("docList").where(
  _.and([
    {
      category
    }
    ,
    _.or(
      [
      {
        fileName: db.RegExp({
          regexp: '.*' + name,
          options: 'i',
        })
      },
      {
        submitter: db.RegExp({
          regexp: '.*' + submitter,
          options: 'i',
        })
      }
      ])
  ])  
    
 ).get()
}